package com.yzycoc.qb78.util;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.resource.ClassPathResource;
import com.yzycoc.qb78.Main;
import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * 创建时间： 2023/10/27
 *
 * @author yzy
 * @version 1.0
 **/
@Slf4j
public class FileQb78Util {
    public static void init() {
        try {

            boolean empty = FileUtil.isEmpty(new File(ExcelUtil.filePath));
            if (empty) {
                FileUtil.touch(ExcelUtil.filePath);
            }
            String rootPath = System.getProperty("user.dir");
            String destinationPath = rootPath + "/config.json";
            File file = new File(rootPath + "\\excel\\");
            if (!file.exists()) {
                file.mkdirs();
            }
            file = new File(destinationPath);
            if (file.exists()) {
                return;
            }
            FileUtil.touch(destinationPath);
            FileUtil.writeString("{\n" +
                    "  \"remark-token\": \"登录token F12 可查看 教学：https://blog.csdn.net/weixin_56408993/article/details/128205814\",\n" +
                    "  \"token\": \"Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX25hbWUiOiJjZXNoaXpoYW5naHVhMSIsImxvZ2luX3VzZXJfa2V5IjoiZmI0NmE4YmYtMmU5ZS00NzcxLWE1ZGYtMjI1M2Y3NTA0ZDM0In0.IDFJg0QiHkZiu52oSvHihPwRpKvVdbbvSbJu-eebNKL7K7f91FmmXBGYCIb44vWIajjigLPG_a7JE006pXchnw\",\n" +
                    "\n" +
                    "  \"remark-frequency\": \"采集频率 防止过快导致封号 单位S\",\n" +
                    "  \"frequency\": 5,\n" +
                    "\n" +
                    "  \"remark-WX\": \"QQ号规则匹配可能涉及的字符\",\n" +
                    "  \"WX\": \"Ч1234567890qwertyuiopasdfghjklzxcvbnm①②③④⑤⑥⑦⑧⑨〇ΟⅤ１２３４５６７８９０ＱＷＥＲＴＹＵＩＯＰＬＫＪＨＧＦＤＳＡＺＸＣＶＢＮＭΙⅡⅢⅣⅤⅦⅧⅨⅩ零\",\n" +
                    "\n" +
                    "  \"remark-WX_HEADER\": \"微信前缀可能包含的字符，用作区分微信和QQ\",\n" +
                    "  \"WX_HEADER\" : \"qwertyuiopasdfghjklzxcvbnm〇ΟⅤＱＷＥＲＴＹＵＩＯＰＬＫＪＨＧＦＤＳＡＺＸＣＶＢＮＭ\",\n" +
                    "\n" +
                    "  \"remark-format\" : \"excel文件保存分类 按秒：yyyy-MM-dd HH:mm:ss (以下配置为每天) \",\n" +
                    "  \"format\" : \"yyyy-MM-dd\"\n" +
                    "}",destinationPath, Charset.defaultCharset());
            log.info("配置文件初始化成功");
        } catch (Exception e) {
            log.info("配置文件初始化失败");
            e.printStackTrace();
        }
    }
}
